define([
    'Util',
    'list',
    'dialog',
    'select',
    'text!tpl/buildInstance/viewConstructInstance.tpl',
    'text!tpl/buildInstance/viewConstructInstanceTable.tpl',
    'tab',
    'cookie',
    '../common/getPath',
    'form',
    'clipboard',
    '../common/getQueryString',
    '../common/dateFormat'
], function(Util, List, Dialog, Select, viewConstruct, viewConstructTable, Tab, $cookie, AjaxPath, Form, Clipboard, getQueryString) {
    require(['style!css/style.css','style!css/construct.css']);
    var $el=null;
    var _indexModule = null,
        list = null,
        tab = null,
        tplId = null,
        getResult=null;


    var initialize = function(indexModule, options, tabItem){
        $el = $(viewConstruct);
        _indexModule = indexModule;

        // 事件--点击切换tab后事件回调
        $(tabItem).on("tabActive", function() {
            tabItem.show(true); // 刷新表单
        });
        //console.log(viewRequirementData)
        tab = tabItem;
        this.content=$el;
        tplId = options.menuId;
        // 业务相关代码
        eventInit();

    };
    //折叠三角
    var changeSlide = function (){
        $(this).toggleClass('tri-left');
        $(this).parent('.t-list-title').siblings().stop().slideToggle();
    };
    var changeSlideBox = function (){
        $(this).children('.tri').toggleClass('tri-left');
        $(this).siblings().stop().slideToggle();
    };
    var tabActive = function() {

    };
    //按钮事件
    var eventInit = function (){
        //页面除dialog按钮功能
        //$el.on('click', '.btnBack', btnBack);//返回
        $el.on('click', '.sliderContainer .tri', changeSlide);//折叠
        $el.on('click', '.sliderMakeContainer', changeSlideBox);//折叠
        $('#tabList li.' + tplId).on('click', tabActive);
        $(".viewConstructTable", $el).html(Util.hdb.compile(viewConstructTable)(getResult));
    };


    return initialize;
});